package com.xjoyt.pay.master.po;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xjoyt.pay.constants.DateConstant;
import com.xjoyt.pay.vo.PayType;
import com.xjoyt.pay.vo.TradeType;

/**
 * 支付通道
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_pay_channel")
public class PayChannel {

//	@Id
//	@GeneratedValue(generator = "uuid")
//	@GenericGenerator(name = "uuid", strategy = "uuid2")
//	@Column(name = "pay_channel_id", length = 36)
//	public String id;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "pay_channel_id", length = 36)
	public long id;

	/**
	 * 通道
	 */
	@OneToOne(targetEntity = Channel.class, cascade = {})
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public Channel channel;

	/**
	 * 成本费率(%)
	 */
	@Column(name = "rate")
	public Double rate;

	/**
	 * 单笔下限金额(分)
	 */
	@Column(name = "`min`")
	public Long min;

	/**
	 * 单笔上限金额(分)
	 */
	@Column(name = "`max`")
	public Long max;

	/**
	 * 当日上限金额(分)
	 */
	@Column(name = "day_max")
	public Long dayMax;

	/**
	 * 类型(微信，支付宝)
	 */
	@Column(name = "pay_type", length = 20)
	@Enumerated(EnumType.STRING)
	public PayType payType;

	/**
	 * 结算类型(如T0、T1)
	 */
	@Column(name = "trade_type", length = 20)
	@Enumerated(EnumType.STRING)
	public TradeType tradeType;

	/**
	 * 固定手续费(元)
	 */
	@Column(name = "money")
	public Long money;

	/**
	 * 权重(优先级别)
	 */
	@Column(name = "`weight`")
	public Integer weight;

	/**
	 * 上限手续费(分)
	 */
	@Column(name = "`limit`")
	public Long limit;

	/**
	 * 下限手续费(分)
	 */
	@Column(name = "`minimum`")
	public Long minimum;

	/**
	 * 适配器下单URL
	 */
	@Column(name = "`url`", length = 255)
	public String url;

	/**
	 * 适配器代付URL
	 */
	@Column(name = "pay_url", length = 255)
	public String payUrl;

	/**
	 * 适配器回调URL
	 */
	@Column(name = "callback_url", length = 255)
	public String callbackUrl;

	// /**
	// * 适配器退款地址
	// */
	// @Column(name = "back_url", length = 255)
	// public String backUrl;

	/**
	 * 录入日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;

	/**
	 * 备注
	 */
	@Column(name = "remark", length = 255)
	public String remark;

}
